// i.d(t, { p: () => r })
import * as THREE from "three"
import Logger from "../utils/Logger"

const s = new Logger("texture")
export default (
  url: string,
  onLoad?: (texture?: THREE.Texture) => void,
  onError?: (e?: ErrorEvent) => void,
  onProgress?: (event?: ProgressEvent<EventTarget>) => void
) => {
  const TextureLoader = new THREE.TextureLoader()
  TextureLoader.crossOrigin = "anonymous"
  return TextureLoader.load(url, onLoad, onProgress, event => {
    s.error(`Failed to load ${url}`)
    !!onError && onError(event)
  })
}
